package Infinite::Sequence::Prime;
use base qw{Infinite::Sequence::Natural};

sub increment {
    my( $this ) = @_;
    my $int = $this->SUPER::increment;
    while( not is_prime($int) ) {
        $int = $this->SUPER::increment;
    }
    $int
}

sub is_prime {
    my( $int ) = @_;
    return undef if $int < 2;
    return 1 if $int == 2;
    
    for my $i ( 2 .. int( sqrt($int)+1 ) ) {
        return undef unless $int % $i
    }
    
    1;
}

1